package smashedapples.core
{
	import flash.events.Event;
	import flash.utils.getQualifiedClassName;
	
	public class Command
	{	
		/**
		 * Constructor 
		 * @param type
		 * @param event
		 * @param view
		 * 
		 */		
		public function Command(event:Event=null,view:*=null):void
		{
			this.event = event;
			this.view = view;
		}
		
		/**
		 * returns the type of event that was fired 
		 * @return 
		 * 
		 */		
		public function get type():String
		{
			return event.type;
		}
		
		
		/**
		 *  the event that was fired 
		 */		
		public var event : Event;
		
		/**
		 *  the Smashed Apples Component that dispatched the Event
		 */		
		public var view : *;
		
		/**
		 * returns the qualified class name of the view as a convenience
		 * 
		 * @return String
		 * 
		 */		
		public function get viewType() : String
		{	
			return (view == null) ? "" : flash.utils.getQualifiedClassName(view)	
		}
		
		/**
		 * Deteremines whether a view is of a certain type 
		 * @param string
		 * @return 
		 * 
		 */		
		public function isViewType(classRef:Class):Boolean
		{
			return (this.view is classRef);	
		}
		
		/**
		 * Determines whether the event type is of a certain type
		 * @param classRef:Class
		 * @return Boolean
		 * 
		 */		
		public function isEventType(classRef:Class):Boolean
		{
			return (this.event is classRef);	
		}
		
		
	}
}